package com.example.project_dish;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.appcompat.app.AlertDialog;

import com.example.project_dish.Dishes.SelectDishActivity;

public class method {
    //返回主界面
    public static void return_main(ImageView imageView){
        imageView.setOnTouchListener(new OnDoubleClickListener(new OnDoubleClickListener.DoubleClickCallback() {
            @Override
            public void onDoubleClick() {
                AlertDialog.Builder builder = new AlertDialog.Builder(imageView.getContext());
                builder.setTitle("您确定要返回主界面吗？");
                builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    @SuppressLint("ClickableViewAccessibility")
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Intent intent = new Intent(imageView.getContext(), OrderFoodActivity.class);
                        imageView.getContext().startActivity(intent);
                    }
                });
                builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                });
                builder.show();
            }
        }));
    }
    // 隐藏状态栏
    public static void status_bar(Activity context){
        Window window = context.getWindow();
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        window.setStatusBarColor(Color.TRANSPARENT);
    }

    // 背景图片透明度
    public static void setBackground(LinearLayout linearLayout,ImageView imageView){
        if (linearLayout != null){
            linearLayout.getBackground().setAlpha(180);
        }else if(imageView != null){
            imageView.getBackground().setAlpha(180);
        }
    }

    // 设置图标大小
}
